package com.beerandjesus.sportofkings.handicapper.dao;

import com.beerandjesus.sportofkings.handicapper.dao.aspect.TransactionBoundary;
import com.beerandjesus.sportofkings.handicapper.model.Sire;
import com.beerandjesus.sportofkings.handicapper.model.TurfSireImpl;

import java.math.BigDecimal;

/**
 * Date: Jun 7, 2012
 * Time: 6:29:37 PM
 */
public class TurfSireDAOImpl extends SireDAOImpl implements TurfSireDAO {

    @TransactionBoundary(datasources= Database.Datasource.TURF_SIRE)
    public void buildDatabase() throws DAOException {
        buildDatabase(LEADING_TURF_SIRES);
    }

    @TransactionBoundary(datasources= Database.Datasource.TURF_SIRE)
    public int getRowCount() throws DAOException {
        return getRowCount(LEADING_TURF_SIRES);
    }

    public Sire getTurfSireByName(String name) throws DAOException {
        return getSireByName(name, LEADING_TURF_SIRES, getConnectionManager().getTurfSireDatabaseConnection());
    }

    protected Sire newSire(String h, BigDecimal p) {
        TurfSireImpl ts = new TurfSireImpl();
        ts.setName(h);
        ts.setWinPercentage(p);
        return ts;
    }

}
